<%--                                                                       --%>
<%-- Copyright (c) 2001-2004 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries.                       --%>
<%--                                                                       --%>

<%@ page language="java" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<script language="javascript" src="<%= request.getContextPath() %>/cs/js/stringFunc.js" type="text/javascript">
</script>


<script language="JavaScript">
function onClickCancel(theForm) {
 theForm.action = '<html:rewrite page="/cs/overview.do" />';
 theForm.submit();
}


function onClickSave(theForm) {
  if (validateForm(theForm)) {
    theForm.submit(); 
  }
  return false;
}

function onLoad()
{
   focus();
//   document.forms[0].name.focus();
}

function validateForm(theForm) {
  if ( theForm.name != null &&  theForm.name.value == '' ) {
    
    <c:if test="${micrositeNaviInfoView.map.isMicrosite}">
      alert('<bean:message key="cs.error.microsite.name"/>');
    </c:if>
    
    <c:if test="${!micrositeNaviInfoView.map.isMicrosite}">
      alert('<bean:message key="cs.error.collaboration.name"/>');
    </c:if>
  
    return false;
  } 

  theForm.name.value = stringTrim( theForm.name.value);

  if (  theForm.description.value.length > 2000 ) {
    alert('<bean:message key="cs.error.description"/>');
    return false;
  }

  if (  theForm.goal.value.length > 2000 ) {
    alert('<bean:message key="cs.error.microsite.goal"/>');
    return false;
  }

  var iconPath = theForm.iconPath.value;
  
  if (!validateIconPath(iconPath)) {
    return false;
  }
  
  // check the icon path for user friendly mesg

  return true;
}

// should not start with 'http' or other weird characters.
// should start with '/'. 
function validateIconPath(iconPath) {
  if (iconPath == null || iconPath.length == 0) return true;
  if (stringTrim(iconPath).length == 0) return true; 
  
  var re = /^(http)/i;
  
  // first test whether starting with http
  var invalidStart = iconPath.match(re);
  
  if (invalidStart) {
    alert("<bean:message key='cs.error.microsite.iconPath1'/>");
    return false;
  }
  
  re = /^\//;
  var validStart = iconPath.match(re);
  if (!validStart) {
    alert("<bean:message key='cs.error.microsite.iconPath2'/>");
    return false;
  }
  
  return true;
}

</script>



<html:form action="/cs/micrositeSave.do">
<bvhtml:hiddenList name="micrositeNaviInfoView" property="urlParams" scope="request"/> 

<!-- Begin display logo and microsite name.  -->
<!-- Zone 5 starts here.  -->
      
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" 
       summary="content area">
  <tr>
    <td valign="top">
    
    <!--start microsite logo and name here-->
    <div class="app_pageTitle">
      <%@ include file="/cs/microsite/micrositeNaviInfo.jsp" %>
    </div> 
    <!--end microsite logo and name here-->
    <!--start title bar here-->
    <div class="app_pageSubtitle">
      <span class="left">
        <bean:define id="msName" name="csMicrositeEditForm" property="name"/>      
        <%String msNameStr = msName.toString();%>
        <bean:message key="cs.edit" arg0="<%=msNameStr%>"/>
      </span>
    </div> 
    <!--end title bar here--> 
  
    <!-- start Page Instructions -->
    <div class="pageInstructions">
      <c:if test="${micrositeNaviInfoView.map.isMicrosite}">
        <bean:message key="cs.microsite.edit.note"/>
      </c:if>
      <c:if test="${!micrositeNaviInfoView.map.isMicrosite}">
        <bean:message key="cs.collaboration.edit.note"/>
      </c:if>
    </div>
    <!-- End Page Instructions -->
    <div class="blockWrap">
    <!--start main content area here-->
    <table class="labelForm" width="100%" border="0" cellspacing="0" 
           cellpadding="0" summary="Edit Microsite">
             
      <tr> 
        <td nowrap width="20%" class="label">
        <c:if test="${micrositeNaviInfoView.map.isMicrosite}">
          <bean:message key="cs.microsite.name"/> *: 
        </c:if>
        <c:if test="${!micrositeNaviInfoView.map.isMicrosite}">
          <bean:message key="cs.collaboration.name"/> *: 
        </c:if>
        
        </td>
        <td width="80%" nowrap class="labelField"> 
          <html:text property="name" size="45" maxlength="80"/>
        </td>
      </tr>
      
      <%-- url link name --%>
      <c:if test="${micrositeNaviInfoView.map.isMicrosite}">
      <tr>
        <td nowrap width="20%" class="label">
          <bean:message key="cs.microsite.url.name"/>:</b></td>
        <td width="80%" nowrap class="labelField">
          <html:textarea property="urlName" rows="4" cols="45"/>
        </td>
      </tr>
      </c:if>
      
      <tr>
        <td nowrap width="20%" class="label">
          <bean:message key="cs.description"/>:</b></td>
        <td width="80%" nowrap class="labelField">
          <html:textarea property="description" rows="4" cols="45"/>
        </td>
      </tr>
  
      <tr>
        <td nowrap width="20%" class="label">
          <bean:message key="cs.goal"/>:
        </td>
        <td width="80%" nowrap class="labelField">
          <html:textarea property="goal" rows="4" cols="45"/>
        </td>
      </tr>
      
      <tr>
        <td nowrap width="20%" class="label">
          <bean:message key="cs.microsite.logo.image.location"/>:
        </td>
        <td width="80%" align=left colspan=3 class="labelField">
          <bean:message key="cs.microsite.logo.edit.note1"/><br>
          <table cellspacing="0" cellpadding="4" border="0">
            <tr>
              <td class="labelField">
                <html:text property="iconPath" size="45" maxlength="255"/>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
	
    <!--start cancel, reset, save bar area here-->
    <div class="pageButtonWrap" align="right">
      <html:reset styleClass="pageButton" property="resetBtn" titleKey="button.reset">
        <bean:message key="button.reset"/>
      </html:reset>
	&nbsp;&nbsp;
                   
      <html:button styleClass="pageButton" property="cancelBtn" titleKey="button.cancel" onclick="onClickCancel(this.form)">
        <bean:message key="button.cancel"/>
      </html:button>
      
      <html:button styleClass="pageButton" property="saveBtn"
             titleKey="button.save" onclick="return onClickSave(this.form);">
        <bean:message key="button.save"/>
      </html:button>
    </div>         
    </div>
    </td>
  </tr>
</table>
 
<!--end cancel, reset, save bar area here-->
</html:form>
